package com.gm.sfc;

import static com.gm.sfc.field.ColumnField.*;
import static com.gm.sfc.util.Utility.*;

import java.util.HashMap;
import java.util.LinkedList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.gm.sfc.adapter.FavoriteAdapter;
import com.gm.sfc.field.IField;
import com.gm.sfc.logic.FavoriteLogic;
import com.gm.sfc.util.LogUtil;

/**
 * Favorite Activity
 * @author $Author: segen.der.gottin@gmail.com $
 * @version $Revision: 22 $
 */
public class FavoriteActivity extends BaseActivity {
    private static final String TAG = "FavoriteActivity";

    private ListView mListView;
    private FavoriteAdapter mFavoriteAdapter;
    private LinkedList<HashMap<IField, Object>> mLinkedList;
    private HashMap<IField, Object> mHashMap;
    private FavoriteLogic mFavoriteLogic;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_favorite);
        mFavoriteLogic = FavoriteLogic.getInstance(getApplicationContext());
        mListView = customFindViewById(this, R.id.list_view);
        try {
            mLinkedList = mFavoriteLogic.getList();
            mFavoriteAdapter = new FavoriteAdapter(getApplicationContext(), mLinkedList);
            mListView.setAdapter(mFavoriteAdapter);
            mListView.setOnItemClickListener(new OnItemClickListener() {
                @SuppressWarnings("unchecked")
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id) {
                    mHashMap = (HashMap<IField, Object>) parent.getAdapter().getItem(position);
                    LogUtil.logD(TAG, getHashmap(mHashMap, title));
                }
            });
        } catch (Exception e) {
        }
    }
}
